﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Cesave.Presentation.Permisos.WinForms.Client.ViewModelBase
{
    public abstract class Command
        : INotifyPropertyChanged
    {

        private bool _enabled;
        private string _displayName;
        private string _key;

        public string Key
        {
            get
            {
                return _key;
            }
            protected set
            {
                _key = value;
            }
        }

        public string DisplayName
        {
            get
            {
                return _displayName;
            }
            protected set
            {
                if (_displayName != value)
                {
                    _displayName = value;
                    OnPropertyChanged(new PropertyChangedEventArgs("DisplayName"));
                }
            }
        }

        protected void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, e);
        }

        public bool Enabled
        {
            get
            {
                return _enabled;
            }
            set
            {
                if (_enabled != value)
                {
                    _enabled = value;
                    OnPropertyChanged(new PropertyChangedEventArgs("Enabled"));
                }
            }
        }

        public abstract void Execute();

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
